import Vue from 'vue'
import VueRouter from 'vue-router'
import NProgress from 'nprogress'

import liux from '../plugin/js/liux'

import { setTimeout } from 'core-js';

Vue.use(VueRouter)

const routes = [
  {
    path:'/',
    component:()=> import('../views/layout.vue'),
    children:[
      {
        path:'',
        component:()=> import('../views/Home'),
        meta:{
          title:'首页'
          
        }
      },
      {
        path:'/userlist',
        component:()=> import('../views/User/UserList.vue'),
        meta:{
          title:'员工',
          module:'员工管理'
        }
      },
      {
        path:'/orderlist',
        component:()=> import('../views/Work/OrderList.vue'),
        meta:{
          title:'业务',
          module:'业务管理'
        }
      }


    ]
  },
  {
    path:'/login',
    meta:{
      title:'登录'
    },
    component:()=>import('../views/User/login.vue')
  }
 
];




const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
  
})
router.beforeEach((to,from,next)=>{
  // 顶部进度条蓝条
  // liux.loadingbar.start()
  NProgress.start()
  document.title = "Liux后台-"+to.meta.title
  setTimeout(()=>{
    next()
  },300)
})
router.afterEach((to,from)=>{
  // liux.loadingbar.finish()
  NProgress.done()
})

export default router
